<template>
    <div id="callBack_khfp_khfp_" class="container-fluid">
        <fieldset class="layui-elem-field layui-field-title" >
            <legend>客户分配</legend>
        </fieldset>
        <table class="layui-hide" id="khfp" lay-filter="khfp"></table>
        <script type="text/html" id="callBack_khfp_khfp_toolbar_">
          <div  id="callBack_khfp_khfp_toolbar_edit_" class="el-button--success el-button el-button--mini is-round" lay-event="edit" style="display: none"  >编辑</div>
          <div class="el-button--primary el-button el-button--mini is-round" lay-event="refresh">刷新</div>
        </script>
        <script type="text/html" id="callBack_khfp_khfp_bar_">
          <div class="el-button--success el-button el-button--mini is-round" lay-event="view" >查看</div>
        </script>
        <div id="khxx" class="padding" style="display: none;">
            <v-khxx v-bind:shadeClose="shadeClose" v-bind:searhDatas="searhDatas" v-bind:searhDatas_="searhDatas_" v-bind:editClose="editClose" v-bind:params="params" ></v-khxx>
        </div>
    </div>
</template>
<script>
    import {formatDateTime} from "../../../../common/js/util"
    import khxx from "../../hotCenter/hwzx/khxx.vue"
    export default {
        props: ['params','cx_','getSeleced_','refresh_'],
        components:{
            'v-khxx':khxx
        },
        data:function(){
            return{
                header:[//列表的头
                    {fixed: 'left',type:'checkbox'}
                    , {fixed: 'left',field: 'id',  title: '序号', sort: true,width:70}
                    , {fixed: 'left',field: 'username', title: '归属员',width: 90}
                    , {field: 'yggh', title: '归属员工号',width: 120}
                    , {field: 'ldhm', title: '来电号码',width:90}
                    , {field: 'khmc', title: '客户名称',width:90}
                    , {field: 'zzjxsj', title: '建档时间',width:240,templet: function(res){return formatDateTime(res.zzjxsj)}}
                    , {field: 'xgfpsj', title: '修改分配时间',width:240,templet: function(res){return formatDateTime(res.xgfpsj)}}
                    , {field: 'dhfsj', title: '待回访时间',width:240,templet: function(res){return formatDateTime(res.dhfsj)}}
                    , {field: 'khxq', title: '客户需求',width: 120}
                    , {field: 'khxb', title: '性别', sort: true,width:80,templet:(res)=>{return res.khxb=='1'?'男':'女';}}
                    , {field: 'gtnr', title: '沟通内容',width:120}
                    , {field: 'zxcp', title: '质询产品',width:120}
                    , {field: 'khbz', title: '备注',width:120}
                    , {fixed: 'right',title: '操作',width: 165,align:'center',templet:"#callBack_khfp_khfp_bar_"}
                ],
                shadeClose:false,
                searhDatas:false,
                searhDatas_:"",
                editClose:false,
                selectedData:"",//选中的数据
            }
        },
        watch:{
            cx_:function () {//cx_改变了就表示需要刷新界面
                noCheckCache = true;
                //查找暂存处理列表
                this.$cache_.layuiCachedTable(this,{
                    elem: "#khfp"
                    , url: burl + 'crm-call-back/list' //数据接口
                    , toolbar: '#callBack_khfp_khfp_toolbar_'
                    , method:'post'
                    , where:{CrmHwzxSearch:this.$parent.params}
                    , height: 400
                    , cols: [this.header]
                    , page: true //开启分页
                });
                layui.table.on('toolbar(khfp)', (obj)=>{
                    var checkStatus = layui.table.checkStatus(obj.config.id);
                    switch(obj.event){
                        case 'edit':
                            var data = checkStatus.data;
                            this.selectedData = data;
                            break;
                        case 'refresh':
                            this.refresh()
                            break;
                    };
                });
                layui.table.on('tool(khfp)', (obj)=>{
                    switch(obj.event){
                        case 'view':
                            allIndex = layer.open({//弹出窗口
                                type: 1,
                                skin: 'layui-layer-rim', //加上边框
                                area: ["70%", "70%"], //宽高
                                close: true,
                                maxmin: true,
                                shadeClose: true,
                                content:$("#khxx"),
                            });
                            this.shadeClose = !this.shadeClose;//关闭遮罩
                            this.searhDatas = !this.searhDatas;//搜索数据
                            this.searhDatas_ = obj.data;//赋值数据
                            this.editClose = !this.editClose;//关闭编辑
                            break;
                    };
                });
            },
            getSeleced_:function () {//拿到选中的
                $("#callBack_khfp_khfp_toolbar_edit_").click();
            },
            refresh_:function () {//刷新客户分配
                this.refresh()
            },
        },
        methods:{
            refresh:function () {//刷新客户分配
                noCheckCache = true;
                layui.table.reload("khfp");
            },
        }
    }
</script>